package io.renren.modules.blog.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.blog.entity.PersonalEntity;
import io.renren.modules.blog.service.PersonalService;
import com.mili.common.utils.PageUtils;
import com.mili.common.utils.R;



/**
 * 
 *
 * @author lujianhong
 * @email milimall@qq.com
 * @date 2020-10-26 14:02:33
 */
@RestController
@RequestMapping("/blog/personal")
public class PersonalController {
    @Autowired
    private PersonalService personalService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("blog:personal:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = personalService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{personalId}")
    @RequiresPermissions("blog:personal:info")
    public R info(@PathVariable("personalId") Integer personalId){
		PersonalEntity personal = personalService.getById(personalId);

        return R.ok().put("personal", personal);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("blog:personal:save")
    public R save(@RequestBody PersonalEntity personal){
		personalService.save(personal);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("blog:personal:update")
    public R update(@RequestBody PersonalEntity personal){
		personalService.updateById(personal);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("blog:personal:delete")
    public R delete(@RequestBody Integer[] personalIds){
		personalService.removeByIds(Arrays.asList(personalIds));

        return R.ok();
    }

}
